HOME = ..

TARGETS = $(VOL)

OBJECTS = $(OBJVOL)

#######
VtkIncDir = /usr/include/vtk
VtkLibDir = -L/usr/lib/vtk-5.4 -L/usr/lib/vtk-5.2
VtkLibs = -lvtkImaging -lvtkGraphics -lvtkCommon -lvtkRendering


########
# Mesa #
########
MesaIncDir = /usr/include/GL /usr/X11R6/include/GL
MesaLibs = -L/usr/X11R6/lib -lXext -lSM -lICE -lX11 -lm
#MesaLibs = -L/usr/X11R6/lib -lGL -lXext -lXt -lSM -lICE -lX11 -lm


###############################
# esto es general

CPP = g++ 

incdir1 = $(HOME)/inc
incdir2 = /usr/include/magick

SRC= $(HOME)/src
OBJ = $(HOME)/obj
bindir=$(HOME)/bin

INCLUDES = -I$(subst :, -I,$(VtkIncDir)) -I$(subst :, -I,$(Mesaincdir)) -I$(subst :, -I,$(incdir2)) -I$(subst :, -I,$(incdir1))

CPPFLAGS = -g -Wno-deprecated



##########################################
# VOL

VOL = vol
OBJVOL =  CasosBase.o Index.o marching.o Model3D.o Point.o Triangle.o Cube.o

installvol: $(bindir)/$(VOL)
$(bindir)/vol: $(OBJ)/vol
	-rm $(bindir)/vol
	cp -p $(OBJ)/vol $(bindir)/vol

vol: $(OBJ)/vol

$(OBJ)/vol: $(addprefix $(OBJ)/, $(OBJVOL))
	$(CPP) $(INCLUDES) -rdynamic $(CPPFLAGS) $(VTKFLAGS) -o $(addprefix $(OBJ)/,$(VOL)) $(addprefix $(OBJ)/, $(OBJVOL)) -lpthread $(VtkLibDir) $(VtkLibs) $(MesaLibs)


#########################################
# reglas generales


$(OBJ)/%.o : %.cpp
	$(CPP) -c $(INCLUDES) $(CPPFLAGS)  $< -o $@


.PHONY: vol

all: directorios $(TARGETS)

clean:
	-rm $(TARGETS)
	-rm $(OBJ)/*.o

cleanall: clean

build: clean all

install: $(subst $(OBJ),$(bindir),$(TARGETS))

directorios:
	@if [ ! -d $(bindir) ]; then mkdir $(bindir); fi
	@if [ ! -d $(OBJ) ]; then mkdir $(OBJ); fi



